Class sbktech.tools.hashjava.bytecode.Environment
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sbktech.tools.hashjava.bytecode.Environment

java.lang.Object
   |
   +----sbktech.tools.hashjava.bytecode.Environment

public class Environment
extends Object
This is the class used to start obfuscating bytecode. It contains all the information needed to process a set of class files, and is instantiated to start the obfuscation process.

To use this class, first implement the BytecodeFactory and Statistics interfaces. These are interfaces used to read or write bytecode (for BytecodeFactory) and generate debugging information (for Statistics)

Next, implement an Obfuscator interface, used to rename symbols defined in the bytecode streams.

Now create an instance of this class to start the process. The high level sequence looks as follows


  Environment env = new Environment(myBytecodeFactory,
                                    myObfuscator,
                                    myStatistics);
  while (<there are more classes to add>)
    {
      env.addClass(<DataInput for the bytecode for class>);
    }
  env.obfuscate();
  env.dump();

Author:
$Author: kbs $
See Also:
BytecodeFactory, Obfuscator, Statistics

Variable Index

 o DEBUG_CORRUPT
Constant indicating if debug information should be altered in ways that tries to break disassemblers/debuggers/decompilers
 o DEBUG_REMOVE
Constant indicating if debug information should be removed.
 o DEBUG_RETAIN
Constant indicating if original debug information should be retained.

Constructor Index

 o Environment(BytecodeFactory, Obfuscator, Statistics)
create a new environment to start off the whole process.

Method Index

 o addClass(DataInput, boolean)
Use this to start adding classes to the environment for obfuscation.
 o dump()
Write out the contents of the current environment into a set of classes.
 o obfuscate()
Start the obfuscating process.
 o setLineNumberDebugging(int)
Control how line number debugging information is written out.
 o setLocalVariableDebugging(int)
Control how local variable table information is written out.
 o setSourceFileDebugging(int)
Control how source file debugging information is written out.

Variables

 o DEBUG_REMOVE
  public final static int DEBUG_REMOVE
Constant indicating if debug information should be removed.
 o DEBUG_CORRUPT
  public final static int DEBUG_CORRUPT
Constant indicating if debug information should be altered in ways that tries to break disassemblers/debuggers/decompilers
 o DEBUG_RETAIN
  public final static int DEBUG_RETAIN
Constant indicating if original debug information should be retained.

Constructors

 o Environment
  public Environment(BytecodeFactory bfactory,
                     Obfuscator obfuscator,
                     Statistics stats)
create a new environment to start off the whole process.
Parameters:
bfactory - This is a class to let the environment read and write Class streams when it is necessary
obfuscator - This is the only way to actually alter the names of symbols encountered in the process.
stats - This is called at various points in the manipulation to entertain the user.

Methods

 o addClass
  public void addClass(DataInput in,
                       boolean resolveFully) throws IOException, BytecodeFormatException
Use this to start adding classes to the environment for obfuscation. The method will also add all the superclasses and interfaces implemented by this class, reading them through the BytecodeFactory interface. Adding a class twice causes no harm, except to slow down the program a little.
Parameters:
in - DataInput that contains the definition of the bytecode to be added.
resolveFully - if true, this will also attempt to add any classes referenced by this class, instead of only the superclasses and interfaces implemented by this class. Exceptions are classes in the java.* package. These will never be resolved fully to save loading time.
Throws: IOException
if the DataInput part of things fail
Throws: BytecodeFormatException
if the bytecode itself is hosed.
See Also:
BytecodeFactory
 o obfuscate
  public void obfuscate()
Start the obfuscating process. This should be called only after all the classes that are involved have been added to the Environment. Is also hands off each class that was added to the environment to the obfuscator.
See Also:
addClass, obfuscate
 o dump
  public void dump() throws IOException
Write out the contents of the current environment into a set of classes.
 o setLineNumberDebugging
  public void setLineNumberDebugging(int val)
Control how line number debugging information is written out. The default setting is DEBUG_REMOVE.
Parameters:
val - is one of DEBUG_REMOVE, DEBUG_CORRUPT or DEBUG_RETAIN
 o setLocalVariableDebugging
  public void setLocalVariableDebugging(int val)
Control how local variable table information is written out. The default setting is DEBUG_REMOVE
Parameters:
val - is one of DEBUG_REMOVE, DEBUG_CORRUPT or DEBUG_RETAIN
 o setSourceFileDebugging
  public void setSourceFileDebugging(int val)
Control how source file debugging information is written out. The default setting is DEBUG_REMOVE
Parameters:
val - is one of DEBUG_REMOVE, DEBUG_CORRUPT or DEBUG_RETAIN

All Packages  Class Hierarchy  This Package  Previous  Next  Index